<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/customer.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="location = '<?php echo $insert; ?>'" class="button"><span><?php echo $button_insert; ?></span></a><a onclick="document.getElementById('form').submit();" class="button"><span><?php echo $button_delete; ?></span></a></div>
    </div>
    <div class="content">
      <form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
              			  <td class="left"><?php if ($sort == 'sector_id') { ?>
				<a href="<?php echo $sort_sector_id; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_sector_id; ?></a>
				<?php } else { ?>
				<a href="<?php echo $sort_sector_id; ?>"><?php echo $column_sector_id; ?></a>
				<?php } ?></td>
			  <td class="left"><?php if ($sort == 'name') { ?>
				<a href="<?php echo $sort_name; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_name; ?></a>
				<?php } else { ?>
				<a href="<?php echo $sort_name; ?>"><?php echo $column_name; ?></a>
				<?php } ?></td>
			  <td class="left"><?php if ($sort == 'code') { ?>
				<a href="<?php echo $sort_code; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_code; ?></a>
				<?php } else { ?>
				<a href="<?php echo $sort_code; ?>"><?php echo $column_code; ?></a>
				<?php } ?></td>
              
              <td class="right"><?php echo $column_action; ?></td>
            </tr>
          </thead>
          <tbody>
          				  <tr class="filter">
				<td></td>
				<td><input type="text" name="filter_sector_id" value="<?php echo $filter_sector_id; ?>" size="12" /></td>
				<td><input type="text" name="filter_name" value="<?php echo $filter_name; ?>" size="12" /></td>
				<td><input type="text" name="filter_code" value="<?php echo $filter_code; ?>" size="12" /></td>
				<td align="right"><a onclick="filter();" class="button"><span><?php echo $button_filter; ?></span></a></td>
			  </tr>
            
            <?php if ($sectors) { ?>
            <?php foreach ($sectors as $sector) { ?>
            <tr>
              <td style="text-align: center;"><?php if ($sector['selected']) { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $sector['sector_id']; ?>" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $sector['sector_id']; ?>" />
                <?php } ?></td>
              			  <td class="left"><?php echo $sector['sector_id']; ?></td>			  <td class="left"><?php echo $sector['name']; ?></td>			  <td class="left"><?php echo $sector['code']; ?></td>
              <td class="right"><?php foreach ($sector['action'] as $action) { ?>
                [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                <?php } ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="5"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=stocks/sector&token=<?php echo $token; ?>';

	var filter_sector_id = $('input[name=\'filter_sector_id\']').attr('value');
	if (filter_sector_id) {
		url += '&filter_sector_id=' + encodeURIComponent(filter_sector_id);
	}

	var filter_name = $('input[name=\'filter_name\']').attr('value');
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}

	var filter_code = $('input[name=\'filter_code\']').attr('value');
	if (filter_code) {
		url += '&filter_code=' + encodeURIComponent(filter_code);
	}

		location = url;
}
//--></script>
<script type="text/javascript"><!--
	$(document).ready(function() {
		$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	});
//--></script>
<script type="text/javascript"><!--
	$('#form input').keydown(function(e) {
		if (e.keyCode == 13) {
			filter();
		}
	});
//--></script>

<?php echo $footer; ?>